package cn.stylefeng.guns.modular.rest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo;
import cn.stylefeng.guns.modular.rest.aop.UserAop;
import cn.stylefeng.guns.modular.tool.model.params.ToolGoodsInstallParam;
import cn.stylefeng.guns.modular.tool.model.result.ToolGoodsInstallResult;
import cn.stylefeng.guns.modular.tool.service.ToolGoodsInstallService;
import cn.stylefeng.guns.sys.modular.system.entity.User;
import cn.stylefeng.roses.core.base.controller.BaseController;
import cn.stylefeng.roses.core.reqres.response.ResponseData;

/**
 * 快递控制器
 */
@Controller
@RequestMapping("/rest/tool")
public class toolController extends BaseController{

    @Autowired
    private UserAop userAop;

    @Autowired
    private ToolGoodsInstallService toolGoodsInstallService;

    /**
     * 查询列表
     */
    @ResponseBody
    @RequestMapping("/list")
    public LayuiPageInfo list(ToolGoodsInstallParam toolGoodsInstallParam,String condition ) {
    	User user = userAop.getUser();
    	toolGoodsInstallParam.setDeptId(user.getDeptId());
        return this.toolGoodsInstallService.findPageBySpec(toolGoodsInstallParam,condition,user.getOperateId());
    }

    /**
     * 编辑接口
     */
    @RequestMapping("/editItem")
    @ResponseBody
    public ResponseData editItem(ToolGoodsInstallParam toolGoodsInstallParam) {
        this.toolGoodsInstallService.update(toolGoodsInstallParam);
        return ResponseData.success();
    }

    /**
     * 查询商品
     */
    @RequestMapping("/getToolGoodsInstall")
    @ResponseBody
    public ResponseData getToolGoodsInstall(ToolGoodsInstallParam toolGoodsInstallParam) {
    	User user = userAop.getUser();
    	toolGoodsInstallParam.setDeptId(user.getDeptId());
    	ToolGoodsInstallResult toolGoodsInstallResult = toolGoodsInstallService.findBySpec(toolGoodsInstallParam,user.getOperateId());
        return ResponseData.success(toolGoodsInstallResult);
    }

    /**
     * 请求一下
     * 接口
     */
    @RequestMapping("/qingqiu")
    @ResponseBody
    public ResponseData qingqiu(ToolGoodsInstallParam toolGoodsInstallParam) {
    	User user = userAop.getUser();
    	toolGoodsInstallParam.setDeptId(user.getDeptId());
    	ToolGoodsInstallResult toolGoodsInstallResult = toolGoodsInstallService.findBySpec(toolGoodsInstallParam,user.getOperateId());
        return ResponseData.success(toolGoodsInstallResult);
    }

}
